<div [@routerTransition]>
    <div class="m-subheader">
        <div class="align-items-center row" style="margin: 0;">
            <div class="float-left" style="min-width: 200px;">
                <h3 class="m-subheader__title m-subheader__title--separator"><span>基础数据</span></h3>
                <span>
                    计量单位
                </span>
            </div>
            <div class="float-right ml-auto" style="margin-left: 10px; min-width: 160px;">
                <button
                    (click)="createOrEditMeasurementUnitModal.show()"
                    *ngIf="permission.isGranted('Pages.BaseData.MeasuremnetUnits.Create')"
                    class="btn btn-primary blue"
                >
                    新增
                </button>
                <!-- <button (click)="excelModal.show('Base_MeasurementUnit', '计量单位', null, 1)" 
          
                    class="btn btn-primary blue">
                    导入
                </button> -->
                <ng-container *ngIf="selectedValues.id">
                    <button
                        (click)="createOrEditMeasurementUnitModal.show(selectedValues.id)"
                        *ngIf="permission.isGranted('Pages.BaseData.MeasuremnetUnits.Edit')"
                        class="btn btn-primary blue"
                        type="submit"
                    >
                        <i [attr.aria-label]="l('Update')"> </i> 更新
                    </button>
                    <button
                        (click)="delete(selectedValues.id)"
                        *ngIf="permission.isGranted('Pages.BaseData.MeasuremnetUnits.Delete')"
                        class="btn btn-danger"
                        type="submit"
                    >
                        <i [attr.aria-label]="l('Delete')"> </i> 删除
                    </button>
                </ng-container>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <div class="tabbable-line">
                    <div class="tab-content" style="padding-top:0;">
                        <div class="tab-pane active" id="tab-model">
                            <div class="row align-items-center">
                                <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                                    <p-table
                                        #dataTable
                                        (onLazyLoad)="getTableData($event)"
                                        [value]="primengTableHelper.records"
                                        [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                        [paginator]="false"
                                        [lazy]="true"
                                        [scrollable]="true"
                                        ScrollWidth="100%"
                                        [responsive]="primengTableHelper.isResponsive"
                                        [resizableColumns]="primengTableHelper.resizableColumns"
                                        selectionMode="single"
                                        [(selection)]="selectedValues"
                                    >
                                        <ng-template pTemplate="header">
                                            <tr>
                                                <th style="width: 40px">
                                                    序号
                                                </th>
                                                <ng-container *ngFor="let ext of extensions">
                                                    <th width="{{ ext.width }}">
                                                        {{ ext.title }}
                                                    </th>
                                                </ng-container>
                                            </tr>
                                        </ng-template>

                                        <ng-template pTemplate="body" let-record="$implicit" let-i="rowIndex">
                                            <tr [pSelectableRow]="record">
                                                <td style="width: 40px">
                                                    {{ i + 1 + paginator.first }}
                                                </td>
                                                <ng-container *ngFor="let ext of extensions">
                                                    <ng-container [ngSwitch]="ext.formatType">
                                                        <ng-container *ngSwitchCase="1">
                                                            <td width="{{ ext.width }}">
                                                                {{ record[ext.key] | number: '1.0-0' }}
                                                            </td>
                                                        </ng-container>
                                                        <ng-container *ngSwitchCase="2">
                                                            <td width="{{ ext.width }}">
                                                                {{ record[ext.key] | number: '1.2-2' }}
                                                            </td>
                                                        </ng-container>
                                                        <ng-container *ngSwitchCase="4">
                                                            <td width="{{ ext.width }}">
                                                                {{ record[ext.key] | momentFormat: 'YYYY-MM-DD' }}
                                                            </td>
                                                        </ng-container>
                                                        <ng-container *ngSwitchDefault>
                                                            <td width="{{ ext.width }}">
                                                                {{ record[ext.key] }}
                                                            </td>
                                                        </ng-container>
                                                    </ng-container>
                                                </ng-container>
                                            </tr>
                                        </ng-template>
                                    </p-table>

                                    <div class="primeng-paging-container">
                                        <p-paginator
                                            [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                            #paginator
                                            (onPageChange)="getTableData($event)"
                                            [totalRecords]="primengTableHelper.totalRecordsCount"
                                            [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage"
                                        >
                                        </p-paginator>
                                        <span class="total-records-count">
                                            {{ l('TotalRecordsCount', primengTableHelper.totalRecordsCount) }}
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <createOrEditMeasurementUnitModal
        #createOrEditMeasurementUnitModal
        (modalSave)="getTableData()"
    ></createOrEditMeasurementUnitModal>
    <!-- <excelModal #excelModal (importEnd)="getTableData()" (importStart)="primengTableHelper.showLoadingIndicator()"></excelModal> -->
</div>
